package com.sjt.thread;

public class YiledTest implements Runnable {
    private String name;

    public YiledTest(String name) {
        this.name = name;
    }

    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println(name + ":" + i);
            if ("t1".equals(name) && i == 5) {
                System.out.println(name + ":" + i + "......yield.............");
                Thread.yield();
            }
        }
    }
    public static void main(String[] args) throws Exception {
        Thread t1 = new Thread(new YiledTest("t1"));
        Thread t2 = new Thread(new YiledTest("t2"));
        t1.start();
        t2.start();
    }
}